<?php

require_once(TANGRA_MAIN_DIR.'form/gform_ctrl_with_obj.class.php');

require_once('rss_channel_form.class.php');
require_once('rss_channel_form_view.class.php');

require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/rss/rss_channel_dbc.class.php');


class RSS_Channel_Form_Ctrl extends GForm_Ctrl_With_Object {
	protected function create_form() {
		$form = new RSS_Channel_Form();

//		$form->generate_html();
		return $form;
	}


	protected function create_form_view() {
		$ret = new RSS_Channel_Form_View($this->form);

		return $ret;
	}


	protected function on_good_submit() {
		$ret = true;


		return $ret;
	}


	protected function on_bad_submit() {

//		printbr('lajna');
	}


	protected function create_object() {
		$object = new RSS_Channel_DBC();

		return $object;
	}


	protected function transfer_obj2form() {
		$object = $this->get_object();
		$form = $this->get_form();

		$form->set_field_value('title', $object->get_title());
		$form->set_field_value('link', $object->get_link());
		$form->set_field_value('description', $object->get_description());
		$form->set_field_value('language', $object->get_language());
		$form->set_field_value('copyright', $object->get_copyright());
		$form->set_field_value('managing_editor', $object->get_managing_editor());
		$form->set_field_value('web_master', $object->get_web_master());
		$form->set_field_value('ttl', $object->get_ttl());
	}


	protected function transfer_form2obj() {
		$object = $this->get_object();
		$form = $this->get_form();

		$object->set_title(trim($form->get_field_value('title')));
		$object->set_link(trim($form->get_field_value('link')));
		$object->set_description(trim($form->get_field_value('description')));
		$object->set_language(trim($form->get_field_value('language')));
		$object->set_copyright(trim($form->get_field_value('copyright')));
		$object->set_managing_editor(trim($form->get_field_value('managing_editor')));
		$object->set_web_master(trim($form->get_field_value('web_master')));
		$object->set_ttl($form->get_field_value('ttl'));
	}
}